# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgbase=nose
pkgname=("python3-${pkgbase}" "python2-${pkgbase}")
pkgver=1.3.7
pkgrel=1
pkgdesc="A discovery-based unittest extension"
arch=('i686' 'x86_64')
license=('LGPL-2.1')
url="http://readthedocs.org/docs/nose/"
makedepends=("python2-setuptools" "python3-setuptools")
source=("http://pypi.python.org/packages/source/n/nose/nose-${pkgver}.tar.gz")
md5sums=('4d3ad0ff07b61373d2cefc89c5d0b20b')

prepare() {
  cd "$srcdir/nose-$pkgver"
  sed -i -e "s:man/man1:share/man/man1:g" setup.py
}

build() {
  cd "$srcdir/nose-$pkgver"
  sed -i -e "s:man/man1:share/man/man1:g" setup.py

  cd "$srcdir"
  rm -rf python{2,3}-build
  for builddir in python{2,3}-build; do
    cp -r nose-$pkgver $builddir
    pushd $builddir
    /usr/bin/${builddir%-build} setup.py build
    popd
  done
}

package_python3-nose() {
  depends=("python3-setuptools")

  cd "$srcdir/python3-build"
  /usr/bin/python3 setup.py install --prefix=/usr --root="$pkgdir" -O1

  rm -f ${pkgdir}/usr/bin/nosetests
  rm -rf "${pkgdir}/usr/share"
}

package_python2-nose() {
  depends=("python2-setuptools")

  cd "$srcdir/python2-build"
  /usr/bin/python2 setup.py install --prefix=/usr --root="$pkgdir" -O1
}
